package com.kitty.record.kittyio.bio.three;

import java.util.concurrent.*;

/**
 * @Description
 * @Author SHEN
 * @Date 2021/2/9
 */
public class SocketThreadPool  {

    private Executor executor;


    public SocketThreadPool() {
        /**
         * 客户端的线程数超过核心线程数会进入等待队列，等待队列塞满了会启用非核心线程来处理任务
         */
        this.executor = new ThreadPoolExecutor(2,
                4,
                120L,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<Runnable>(4),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy());

    }


    public void execute(Runnable task){
        this.executor.execute(task);
    }
}
